<!--
 * @Author: Rachel 943701297@qq.com
 * @Date: 2022-07-11 10:43:25
 * @LastEditors: Rachel 943701297@qq.com
 * @LastEditTime: 2022-07-11 11:03:37
 * @FilePath: \JS\java-script-learning-notes\JSCode\flex布局.html
 * @Description: 
 * 
 * Copyright (c) 2022 by Rachel 943701297@qq.com, All Rights Reserved. 
-->
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>居中对齐</title>
    <style>
      * {
        padding: 0;
        margin: 0;
      }
      #box2 {
        position: absolute;
        width: 100px;
        height: 100px;
        left: 50%;
        top: 50%;
        margin-left: -50px;
        margin-top: -50px;
        background-color: red;
      }
      #box1 {
        /* display: flex;
        justify-content: center;
        align-items: center;
        background-color: yellow; */
        position: relative;
        height: 300px;
        background-color: yellow;
      }
    </style>
  </head>
  <body>
    <div id="box1">
      <div id="box2"></div>
    </div>
  </body>
</html>
